package com.itheima.udp;

import java.io.IOException;
import java.net.DatagramPacket;
import java.net.DatagramSocket;
import java.net.InetAddress;
import java.util.Scanner;
//组播练习，发送端
public class SockdetDemoZuBo01 {
    public static void main(String[] args) throws IOException {
        //创建DatagramSocket对象
        DatagramSocket da=new DatagramSocket();
        String s="哈哈哈";
        byte[]bytes=s.getBytes();
        //发送组播地址
        InetAddress name = InetAddress.getByName("224.0.0.3");
        int port=8080;
        //创建数据，数据打包
        DatagramPacket dp=new DatagramPacket(bytes,bytes.length,name,port);
        //发送
        da.send(dp);
        //释放
        da.close();
    }
}
